
<!DOCTYPE html>
<html>
<!--Made By kailuosoft.com, TEL 171 9992 9517 -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>凯络科技后台管理系统 - 添加/编辑用户</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="__PUBLIC__/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/css/animate.min.css" rel="stylesheet">
    <link href="__PUBLIC__/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="__PUBLIC__/css/new.css" rel="stylesheet">
	
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <if condition=" !empty($res4)"> 
                           <h5>编辑用户</h5>
                        <else/>
                           <h5>添加用户</h5>
                        </if>
                        
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="commentForm" action="{:U('Index/user_add')}" method="post">
							<input type='hidden' name="id" id='id' value='<if condition=" !empty($res4)"> {$res4.id} </if>' />
                            <div class="form-group">
                                <label class="col-sm-3 control-label">用户名：</label>
                                <div class="col-sm-8">
                                    <input id="username" name="username" minlength="2" type="text" class="form-input" required aria-required="true" placeholder='请输入至少2个字符的用户名' autocomplete="off" {$res4?"disabled":""} onfocus="this.type='password'" value='<if condition=" !empty($res4)"> {$res4.username} </if>'>
                                </div>
                            </div>
							<div class="form-group">
                                <label class="col-sm-3 control-label">密码：</label>
                                <div class="col-sm-8">
                                    <input id="password" name="password" minlength="6" type="password" class="form-input" required aria-required="true" placeholder='请输入至少6个字符的密码'>
                                    <if condition=" !empty($res4)"> 
                                      <span>不修改请留空</span>
                                    </if>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">E-mail：</label>
                                <div class="col-sm-8">
                                    <input id="cemail" type="email" class="form-input" name="email" placeholder='请入正确的邮箱' value='<if condition=" !empty($res4)"> {$res4.email} </if>'>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">phone：</label>
                                <div class="col-sm-8">
                                    <input id="phone" type="phone" class="form-input" name="phone"  placeholder='请输入电话' value='<if condition=" !empty($res4)"> {$res4.phone} </if>'>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3">
                                   <span class="btn btn-primary" id='submit'>提交</span>
                                   <input type='reset' class="btn btn-primary">
                                   <if condition=" !empty($res4)"> 
                                    <a class="btn btn-primary" href='javascript:history.back(-1)'>返回</a>
                                   </if>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="__PUBLIC__/js/jquery.min63b9.js?v=2.1.4"></script>
    <script src="__PUBLIC__/js/bootstrap.min14ed.js?v=3.3.6"></script>
    <script src="__PUBLIC__/js/content.mine209.js?v=1.0.0"></script>
    <script src="__PUBLIC__/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="__PUBLIC__/js/plugins/validate/messages_zh.min.js"></script>
    <script src="__PUBLIC__/js/demo/form-validate-demo.min.js"></script>
    <script src="__PUBLIC__/js/plugins/layer/layer.min.js"></script>
   

<script>
    $('#submit').click(function(event){
		 event.preventDefault();
		 event.stopPropagation();
		
		 var id=$('#id').val();
		 var username=$('#username').val();
		 var password=$('#password').val();
		 var email=$('#cemail').val();
		 var phone=$('#phone').val();
		 
		 user_error=$('#username-error').text();
		 pw_error=$('#password-error').text();
		 email_error=$('#cemail-error').text();
		 
		 info="{$res4}";
		 if(username=='')
		 {   
			 return false;
		 }
		 if(user_error!='' || pw_error!='' || email_error!='')
		 {
			 return false;
		 }
		 if(info=='' && password=='')
		 {
			 return false;
		 }
		 
		 $.ajax({
			 //url: '{:U("Admin/admin_add")}',
			 url: '/index.php/home/index/user_update',
			 type:'POST',
			 data:'id='+id+'&username='+username+'&password='+password+'&email='+email+'&phone='+phone,
			 success:function(data){
				if(data==0){
					layer.alert('新增失败','',function(){location.href='user_list'});
				}else if(data==1){
					layer.alert('新增成功','',function(){location.href='user_list'});
				}else if(data==2){
				
					layer.alert('修改成功','',function(){self.location=document.referrer;});
				}else if(data==3){
					console.log($data);return false;
					layer.alert('修改失败','',function(){self.location=document.referrer;});
				}else if(data==4){
					layer.alert('该用户名已存在');
				}
			}
		 })
	})
</script>

</body>
<!--Made By kailuosoft.com, TEL 171 9992 9517 -->
<script  type="text/javascript"  src="http://g.tbcdn.cn/sj/securesdk/0.0.3/securesdk_v2.js"  id="J_secure_sdk_v2" data-appkey="23416550"></script>
</html>
